package com.cuit.spring.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JwtInterceptor jwtInterceptor(){
        return new JwtInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("正在加载JWT拦截器 ...");
        registry.addInterceptor(jwtInterceptor())
                .addPathPatterns("/**") //拦截请求
                .excludePathPatterns("/user/login","/user.register","/**/export","/**/import","/file/**");
    }
}
